package com.example.ali.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.ali.R;
import com.example.ali.entiy.School;

import java.util.ArrayList;

/**
 * Created by 落叶的思恋 on 2018/4/12.
 */

public class SchooltListViewAdpter extends BaseAdapter {
    private LayoutInflater mInflater;
    private ArrayList<School> schoolArrayList;

    public SchooltListViewAdpter(Context context, ArrayList<School> schoolArrayList) {
        this.mInflater = LayoutInflater.from(context);
        this.schoolArrayList = schoolArrayList;
    }


    @Override
    public int getCount() {

        return schoolArrayList.size();
    }

    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return schoolArrayList.get(arg0);
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return arg0;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ImageView img1 = null, img2 = null, img3 = null;
        TextView title = null, time = null, connent = null;
        LinearLayout relativeLayout = null;
        School school = new School();

        convertView = mInflater.inflate(R.layout.student_listview_item, null);
        img1 = (ImageView) convertView.findViewById(R.id.ImageView1);
        img2 = (ImageView) convertView.findViewById(R.id.ImageView2);
        img3 = (ImageView) convertView.findViewById(R.id.ImageView3);
        title = (TextView) convertView.findViewById(R.id.title);
        time = (TextView) convertView.findViewById(R.id.time);
        connent = (TextView) convertView.findViewById(R.id.content);
        relativeLayout = (LinearLayout) convertView.findViewById(R.id.school);

        school = (School) getItem(position);
        img1.setImageResource(school.getImg()[0]);
        img2.setImageResource(school.getImg()[1]);
        img3.setImageResource(school.getImg()[2]);
        title.setText(school.getTitle());
        connent.setText(school.getContent());
        time.setText(school.getData());
        relativeLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });


        return convertView;
    }


}
